<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path;
%>
<!DOCTYPE html>
<html lang="zh"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<!-- 
<link rel="icon" href="./images/favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="./images/favicon.ico" type="image/x-icon">
 -->
<title>运维管理系统</title>
<link rel="stylesheet" type="text/css" href="./static/css/site.css">
<link rel="stylesheet" type="text/css" href="./static/css/login.css">

<link rel="stylesheet" href="./static/css/layer.css" id="layuicss-skinlayercss"></head>

<body style="">
        <style type="text/css">
                @media screen and (max-width: 640px) {
                    .account{
                        display: block !important;
                    }
                }
                .main .login .rlogo{
                        margin-top: 15px;
                        margin-bottom: 25px;
                }
        </style>
<div class="main">
        <div class="login">
                <div class="account">
                        <form class="loginform" method="post" action="<%=basePath%>/login" onsubmit="return false;">
                        <div class="rlogo">运维管理系统</div>
                        <div class="line"><input class="inputtxt" value="" name="username" datatype="*" nullmsg="请填写账号" errormsg="格式不对" placeholder="账号" type="text"><div class="Validform_checktip Validform_right"></div></div>
                        <div class="line"><input class="inputtxt" name="password" value="" datatype="*" nullmsg="请填写密码" errormsg="请填写密码" placeholder="密码" type="password"><div class="Validform_checktip Validform_right"></div></div>
                        <div style="color: red;position: relative;top: -14px;" id="errorStr"></div>
                        <div class="line yzm" style="top: -5px; ">
                                <input type="text" class="inputtxt" name="code" nullmsg="请填写4位验证码" errormsg="验证码不对" datatype="*" placeholder="请填写验证码" style="width: 220px;">
                                <div class="Validform_checktip"></div>
                                <img width="100" height="40" class="passcode" onclick="this.src=this.src.split(&#39;?&#39;)[0] + &#39;?&#39;+new Date().getTime()" src="<%=basePath%>/code" style="border: 1px solid #ccc; float: right" title="点击换一张">
                        </div>
                        <div class="login_btn"><input id="login-button" value="登录" type="submit"></div>
                        <!-- <p class="pwinfo" style="display:none">3次以上登录错误将会出现验证码</p> -->
                        </form>
                </div>
        </div>
</div>
<script type="text/javascript" src="./static/js/jquery-1.10.2.min.js"></script>
<script src="./static/js/zh-cn.js"></script>
<script src="./static/js/lan.js"></script>
<script type="text/javascript" src="./static/js/layer.js"></script>
<script type="text/javascript" src="./static/js/Validform_v5.3.2_min.js"></script>
<script type="text/javascript">
        function Wreset(){
                var w = $(window).width();
                var yzmw = $(".login .line").width() - 140;
                if($(".yzm").is(":visible") && w > 640){
                        $(".login").css({"height":"365px","margin-top":"-230px"});
                }
                else{
                        $(".login").removeAttr("style")
                }
                $(".login .yzm .inputtxt").width(yzmw);
        }
        $(function(){
                Wreset();
        })
        window.onresize=function(){
                Wreset();
        }
        </script>
        <script type="text/javascript">
        $(function(){
                $(".loginform").Validform({
                        tiptype:function(msg,o,cssctl){
                                if(!o.obj.is("form")){
                                        var objtip=o.obj.siblings(".Validform_checktip");
                                        cssctl(objtip,o.type);
                                        objtip.text(msg);
                                }
                        }
                });
        });
        
        $('#login-button').click(function(){
                var username = encodeURIComponent($("input[name='username']").val());
                var password = encodeURIComponent($("input[name='password']").val());
                var code = $("input[name='code']").val();
                if(username == '' || password == '' || code == ''){
                        layer.msg("表单错误,请重新输入!",{icon:2});
                        return;
                }
                                
                var data = 'username='+username+'&password='+password+'&code='+code;
                var loadT = layer.msg("正在登录...",{icon:16,time:0,shade: [0.3, '#000']});
                $.post('<%=basePath%>/login',data,function(rdata){
                        layer.close(loadT);
                        if(!rdata.status){
                        	console.log("rdata");
                            $("#errorStr").html(rdata.msg);
                            $("input[name='password']").val('');
                            $(".login").css("height","332px");
                            $("input[name='code']").val('');
                            $(".passcode").click();
                            Wreset();
                            layer.msg(rdata.msg,{icon:2,time:5000});
                            return;
                        }
                        
                        layer.msg(rdata.msg,{icon:16,time:0,shade: [0.3, '#000']});
                        window.location.href = '<%=basePath%>/console';
                });
        });

</script>


</body></html>